<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<%@include file="../../common/Include_input_head.jsp" %>
  		<title>消息发送</title>

	<script type="text/javascript" src="${basePath }/resources/js/p2pMessage.js"></script>
	
	<script type="text/javascript">

	var tem_valueObjid,tem_nameObjid;
	function selectDepart(valueObjid,nameObjid){
		tem_valueObjid = valueObjid;
		tem_nameObjid = nameObjid;
		var depart = '<s:property value="depart.departtype" />';
		var isISHUNAN = '<s:property value="@com.imchooser.infoms.action.sys.BaseActionAbstractSupport@isISHUNAN()"/>';
		if(depart =='1' && isISHUNAN=='true'){
			var url = "${basePath }/system/depart-selectDepartName.c";
		}else{
			var url = "${basePath }/system/depart-selectDepart.c";
		}
		openWindow(url,700,300);
	}
	function selectStudent(valueObjid,nameObjid){
		tem_valueObjid = valueObjid;
		tem_nameObjid = nameObjid;
		$("#xxlx").val("051");
		var url = "${basePath }/business/xsfwStudent-selectStudent.c";
		openWindow(url,700,300);
		if(document.getElementById("xxjsrName").value == '全部学生'){
			document.getElementById("xxjsrName").value = '';
			document.getElementById("xxjsr").value = '';
		}
	}
	function AllStudent(){
		$("#xxlx").val("050");
		document.getElementById("xxjsrName").value = '全部学生';
		document.getElementById("xxjsr").value = '0';
	}
	function submitForm(str){
		if(document.getElementsByName('tsysMessage.xxlx')[1].checked && document.getElementById("xxjsr").value==""){
			alert("请选择消息接收者！");
			return false;
		}
		var xxbt = document.getElementById("xxbt").value;
		if(xxbt==""){
			alert("请输入标题！");
			return false;
		}
		if(getLength(xxbt)>150){
			alert("标题字数超出最大值！");
			return false;
		}
		var xxnr = document.getElementById("xxnr").value;
		if(xxnr==""){
			alert("请输入内容！");
			return false;
		}
		if(getLength(document.getElementById("xxnr").value)>1500){
			alert("内容字数超出最大值！");
			return false;
		}
		document.getElementById("fszt").value = str;
		return super_doSave(false);
	}
	function doReset(obj){
	     document.getElementById(obj).focus();
	     document.execCommand("selectall");   
         document.execCommand("Delete"); 
	}
	function PreviewFile(myFile,index){
	    var filepath=myFile.value;
	    var id = "fjm"+index;
	    document.getElementById(id).value=filepath.substring(filepath.lastIndexOf('.')+1,filepath.length);
	}
	function postNoDeparts(){
		document.getElementById('xxjsrName').value = '';
		document.getElementById('xxjsr').value = '';
	}
	function changeXxlx(){//消息类型变化	
		if(document.getElementsByName('tsysMessage.xxlx')[0].checked){
			document.getElementById('jsrline').style.display = "none";
		}else{
			document.getElementById('jsrline').style.display = "";
		}
	}
	function init(){
		document.getElementById('xxbt').value = "";
		document.getElementById('xxnr').value = "";
		changeXxlx();
	}
	function addFj(fjName){
		document.getElementById(fjName).style.display = "";
	}
	function displayFj(fjName){
		document.getElementById(fjName).style.display = "none";
	}
	function search(valueObjid,nameObjid,deptype){
		tem_valueObjid = valueObjid;
		tem_nameObjid = nameObjid;
		var url = "${basePath }/system/depart-selectDepartName.c?deptype="+deptype+"";
		openWindow(url,700,300);
		//super_doSearch();
	}

	window.onload = init;
	</script>
  	<base target="_self">
  </head>
  
  <body>

<div class="box1" >
  <s:form name="theform" method="post" theme="simple" enctype="multipart/form-data">
  <s:hidden id="xxjsrName" name="tsysMessage.xxjsrName" />
  <s:hidden id="fszt" name="tsysMessage.fszt"/>
  
  <table width="100%" border="0" align="">
    <tr>
      	<td align="right" width="18%" nowrap="nowrap">消息类型：</td>
    	<td nowrap="nowrap" align="left">
	      <s:radio name="tsysMessage.xxlx" list="#{'101':'全站通知','102':'指定用户'}" onclick="changeXxlx()"/> <label style="color:red">*</label>
	    </td>
	</tr>
    <tr id="jsrline"> 
      <td align="right" nowrap="nowrap">接收者：</td>
      <td>
	      <s:textfield name="tsysMessage.xxjsr" id="xxjsr" maxlength="500" cssStyle="width:500px"/> <label style="color:red">*</label>
      </td>
    </tr>
    <tr class="fzline"> 
      <td align="right" nowrap="nowrap">标题：</td>
      <td><s:textfield id="xxbt" name="tsysMessage.xxbt" maxlength="150" cssStyle="width:500px"/> <label style="color:red">*</label></td>
    </tr>
    <tr class="fzline">
     <td align="right" nowrap="nowrap">内容：</td>
      <td><s:textarea id="xxnr" name="tsysMessage.xxnr" cssStyle="width:500px"></s:textarea> <label style="color:red">*</label></td>
    </tr>
	<tr>
		<td align="right" nowrap="nowrap">附件：</td>
			 <td><input id="myFile0" name="myFile" type="file" onchange="javascript:PreviewFile(this,'');"/>
			     <input type="button" name="Submit3" value="清除" onclick="doReset('myFile0')"/>&nbsp;&nbsp;
			     <s:hidden id="fjm" name="tsysMessage.fjm"/></td>
	</tr> 
    </table>
  
</s:form>
</div>

<div class="padding_top10">
		<table class="tableStyle" transMode="true">
			<tr>
				<td colspan="4">
					<input type="button" id="" value=" 发 送 " onclick="submitForm('1')"/>
					<input type="button" value=" 关 闭 " onclick="parent.closeEntityWindow()"/>
					<s:if test="actionErrors.size()>0 || actionMessages.size()>0 || fieldErrors.size()>0">
						<span id="SystemErrorMessage" style="top: 20px">
							<s:actionerror cssStyle="color:red"/>
							<s:actionmessage cssStyle="color:blue"/>
							<s:fielderror/>
						</span>
					</s:if>
				</td>
			</tr>
		</table>
</div> 

  </body>
</html>
